/* 全局样式 */
:root {
    --primary: #3498db;
    --primary-dark: #2980b9;
    --secondary: #2ecc71;
    --secondary-dark: #27ae60;
    --accent: #9b59b6;
    --danger: #e74c3c;
    --warning: #f39c12;
    --dark: #2c3e50;
    --light: #ecf0f1;
    --gray: #95a5a6;
    --text: #34495e;
    --border: #dde1e2;
    --card-bg: #ffffff;
    --panel-bg: #f9f9f9;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    --radius: 10px;
    --transition: all 0.3s ease;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    line-height: 1.6;
    background: linear-gradient(135deg, #f5f7fa 0%, #e4edf5 100%);
    color: var(--text);
    padding: 20px;
    min-height: 100vh;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

/* 头部样式 */
header {
    background: linear-gradient(120deg, var(--dark) 0%, var(--primary) 100%);
    color: white;
    padding: 25px 30px;
    text-align: center;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 150px;
    height: 150px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

header::after {
    content: '';
    position: absolute;
    bottom: -30px;
    left: -30px;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

header h1 {
    margin: 0;
    font-size: 2.2rem;
    font-weight: 500;
    position: relative;
    z-index: 2;
}

/* 主内容区域 */
main {
    padding: 25px 30px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

@media (max-width: 900px) {
    main {
        grid-template-columns: 1fr;
    }
}

/* 面板样式 */
.panel {
    background: var(--card-bg);
    margin-bottom: 25px;
    padding: 25px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.panel:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.1);
}

.panel h2 {
    margin-top: 0;
    color: var(--dark);
    font-size: 1.5rem;
    padding-bottom: 15px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--light);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel h2::before {
    content: '';
    width: 6px;
    height: 24px;
    background: var(--primary);
    border-radius: 3px;
}

/* 按钮样式 */
.button, .button-primary, .button-small {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 22px;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background: var(--primary);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: var(--transition);
    box-shadow: 0 2px 6px rgba(52, 152, 219, 0.3);
}

.button:hover, .button-primary:hover, .button-small:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(52, 152, 219, 0.4);
}

.button:active, .button-primary:active, .button-small:active {
    transform: translateY(0px);
}

.button-primary {
    background: var(--secondary);
    padding: 14px 28px;
    font-size: 1.1rem;
}

.button-primary:hover {
    background: var(--secondary-dark);
    box-shadow: 0 4px 10px rgba(46, 204, 113, 0.4);
}

.button-small {
    padding: 8px 16px;
    font-size: 0.9rem;
    margin-right: 5px;
    margin-bottom: 5px;
}

/* 音频控制区域 */
.audio-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: center;
    margin-bottom: 15px;
}

.upload-section {
    display: flex;
    align-items: center;
    gap: 15px;
}

#uploaded-ref-filename {
    font-style: italic;
    color: var(--gray);
    font-size: 0.95rem;
}

#waveform-container, #output-waveform-container {
    width: 100%;
    height: 100px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 15px;
}

.wavesurfer-region {
    background-color: rgba(52, 152, 219, 0.3) !important;
    z-index: 2 !important;
}

.wavesurfer-handle {
    background-color: rgba(0, 0, 0, 0.5) !important;
    width: 6px !important;
}

#waveform-controls, #output-waveform-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.crop-controls {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px dashed var(--border);
    display: grid;
    grid-template-columns: auto 1fr auto 1fr auto;
    gap: 10px;
    align-items: center;
}

.crop-controls label {
    font-weight: 500;
}

.crop-controls input[type="number"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* 可折叠区域 */
.collapsible-trigger {
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.collapsible-trigger .arrow {
    transition: transform 0.3s ease;
}

.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, padding 0.4s ease-out;
    padding-left: 10px;
    padding-right: 10px;
}

.collapsible.open .collapsible-content {
    max-height: 1000px;
    padding-top: 15px;
    padding-bottom: 15px;
}

.collapsible.open .collapsible-trigger .arrow {
    transform: rotate(180deg);
}

/* 规则集管理 */
.ruleset-management {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

#ruleset-list-container {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    background: var(--panel-bg);
    max-height: 200px;
    overflow-y: auto;
}

.ruleset-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
    border-radius: 6px;
    margin-bottom: 5px;
}

.ruleset-list-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.ruleset-list-item:hover {
    background: #edf2f7;
}

.ruleset-list-item.selected-ruleset {
    background: #e1f0fa;
    font-weight: 500;
    border-left: 4px solid var(--primary);
}

.ruleset-list-item .ruleset-name-display {
    flex-grow: 1;
    margin-right: 10px;
}

/* 预览区域 */
.preview-section {
    margin-top: 20px;
}

.preview-box {
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
    padding: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--panel-bg);
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.6;
    font-size: 1rem;
}

/* 状态消息 */
.status {
    margin-top: 15px;
    padding: 15px;
    border-radius: 8px;
    display: none;
    font-size: 0.95rem;
}

.status.success {
    background: #d4f5e0;
    color: #155724;
    border: 1px solid #c3e6cb;
    display: block;
}

.status.error {
    background: #fdecea;
    color: #721c24;
    border: 1px solid #f5c6cb;
    display: block;
}

.status.info {
    background: #e1f5fe;
    color: #0c5460;
    border: 1px solid #bee5eb;
    display: block;
}

.status.warning {
    background: #fff8e1;
    color: #856404;
    border: 1px solid #ffeeba;
    display: block;
}

/* 高级设置表单 */
#advanced-settings-form {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 15px;
}

.adv-setting-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 15px;
    background: var(--panel-bg);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.adv-setting-item label {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.adv-setting-item input[type="range"] + span {
    font-size: 0.9rem;
    color: var(--text);
    margin-left: 5px;
}

/* 编辑器面板 */
#ruleset-editor-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

#ruleset-editor-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    overflow-y: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    padding: 30px;
}

#ruleset-editor-panel h2 {
    margin-top: 0;
    color: var(--dark);
    font-size: 1.6rem;
    padding-bottom: 15px;
    margin-bottom: 25px;
}
        
.stat-label {
    width: 100px;
    color: var(--text);
    flex-shrink: 0;
    font-weight: 500;
}

.progress-bar-container {
    flex-grow: 1;
    height: 20px;
    background: #edf2f7;
    border-radius: 4px;
    overflow: hidden;
    margin: 0 10px;
    border: 1px solid #cbd5e0;
}

.progress-bar {
    height: 100%;
    transition: width 0.3s ease-in-out;
}

/* 页脚 */
footer {
    text-align: center;
    padding: 20px 30px;
    font-size: 0.9rem;
    color: var(--gray);
    background: var(--light);
    border-top: 1px solid var(--border);
}

/* 响应式调整 */
@media (max-width: 768px) {
    .panel {
        padding: 20px;
    }
    
    .crop-controls {
        grid-template-columns: 1fr;
    }
    
    .synthesis-buttons-container {
        flex-direction: column;
    }
    
    .synthesis-buttons-container .button-primary {
        width: 100%;
    }
}

/* 图标样式 */
.icon {
    width: 20px;
    height: 20px;
    display: inline-block;
    vertical-align: middle;
    margin-right: 5px;
}

/* 文本区域 */
textarea, select, input[type="text"], input[type="number"] {
    width: 100%;
    padding: 14px;
    margin-bottom: 15px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
}

textarea:focus, select:focus, input[type="text"]:focus, input[type="number"]:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.15);
}

textarea {
    resize: vertical;
    min-height: 150px;
    font-family: inherit;
}

/* 替换规则 */
.replacement-rule {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
    align-items: center;
}

.replacement-rule input {
    flex: 1;
    margin-bottom: 0;
}

.replacement-rule .remove-rule-button {
    background: var(--danger);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.replacement-rule .remove-rule-button:hover {
    background: #c0392b;
}

/* 布局优化 */
.panel-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 25px;
}

.full-width {
    grid-column: 1 / -1;
}

.synthesis-controls-panel {
    text-align: center;
}

.synthesis-buttons-container {
    display: flex;
    gap: 20px;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 15px;
}

.synthesis-buttons-container .button-primary {
    flex-grow: 1;
    min-width: 200px;
}

/* 保存的声音特征 */
.saved-voices-section {
    margin-top: 20px;
}

#saved-voices-list-container {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    margin-top: 10px;
    background: var(--panel-bg);
}
.history-audio-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    margin-bottom: 10px;
    background: var(--panel-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: var(--transition);
}

.history-audio-item:hover {
    background: #edf2f7;
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.history-audio-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.history-audio-filename {
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-audio-date {
    font-size: 0.85rem;
    color: var(--gray);
}

.history-audio-actions {
    display: flex;
    gap: 8px;
    margin-left: 15px;
}

.history-audio-play-btn,
.history-audio-download-btn {
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.history-audio-play-btn {
    background: var(--primary);
    color: white;
    border: none;
}

.history-audio-play-btn:hover {
    background: var(--primary-dark);
}

.history-audio-download-btn {
    background: var(--secondary);
    color: white;
    border: none;
}

.history-audio-download-btn:hover {
    background: var(--secondary-dark);
}

#history-audio-list-container {
    max-height: 400px;
    overflow-y: auto;
    padding: 5px;
}

.history-audio-delete-btn {
    background-color: #810505b2;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 8px;
    transition: background-color 0.2s;
}
 
.history-audio-delete-btn:hover {
    background-color: #4702026c;
}